<?php 
	require_once ('checks.php');
	require_once ('Database.php');
	require_once ('Image.php');
	$db = new DB();
	if (isset($_GET['image_name'])) {
		$img= $db->extractImage($_GET['image_name']);
		unlink("images/gallery/".$img->getName());
		$db->deleteRecordInGallery($img);
	}
 ?>

		
		<form method="post" action="?page=admin_delete_image">
			<table border="1">
				<tr>

					<?php
								$arr=$db->takeGallery();
								$n= count($arr);
								for ($i=0;$i<$n;$i++) {
									echo"\n <td><a href='?page=admin_delete_image&image_name=".$arr[$i]->getName()."' onclick=\"return confirm('Сигурни ли сте че искате да я изтриете?');\">
										<img src='images/gallery/".$arr[$i]->getName()."' width='80' height='80'></a></td>";
									if (($i+1) % 10 == 0 && ($i+1)!=$n ) echo "\n</tr>\n<tr>\n";
								}
							?>
					
				</tr>
			</table>
		</form>